//
//  TextFieldTest3ViewController.swift
//  iOS-RxSwift-Tutorials_Example
//
//  Created by mengru.tian on 2020/9/20.
//  Copyright © 2020 CocoaPods. All rights reserved.
//

import UIKit
import RxSwift

class TextFieldTest3ViewController: UIViewController {

    @IBOutlet weak var textField: UITextField!
    @IBOutlet weak var textField2: UITextField!
    @IBOutlet weak var label: UILabel!
    
    let disposeBag = DisposeBag()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        title = "20.3 同时监听多个 textField 内容的变化（textView 同理）"
        view.backgroundColor = .white
        
        test()
    }
    
    func test() {
        
        Observable.combineLatest(textField.rx.text.orEmpty, textField2.rx.text.orEmpty) {
        textValue1, textValue2 -> String in
        return "你输入的号码是：\(textValue1)-\(textValue2)"
        }
        .map { $0 }
        .bind(to: label.rx.text)
        .disposed(by: disposeBag)
    }

}
